#include "chooselevelscene.h"
#include<QMenuBar>
#include<QPainter>
#include<pushbutton.h>
#include<QDebug>
ChooseLevelScene::ChooseLevelScene(QWidget *parent) : QMainWindow(parent)
{
    //配置选择关卡的场景
    this->setFixedSize(430,670);

    //设置图标
    this->setWindowIcon(QPixmap(":/new/prefix1/pic/coind.png"));

    //设置标题
    this->setWindowTitle("赶紧选一关，别磨叽了");//选择关卡上的标题

    //创建菜单栏
      QMenuBar * bar=menuBar();
      setMenuBar(bar);
    //创建开始菜单
     QMenu * startMenu=bar->addMenu("开始");
     //创建退出菜单项
     QAction * quitAction=startMenu->addAction("又不想玩了？");

     //点击退出，实现退出游戏
     connect(quitAction,&QAction::triggered,[=](){
         this->close();
     });

     //返回按钮
     pushbutton * backBtn = new pushbutton(":/new/prefix1/pic/BackButton.png",":/new/prefix1/pic/BackButtonSelected.png");
     backBtn->setParent(this);
     backBtn->move(this->width()-backBtn->width(),this->height()-backBtn->height());//横纵坐标

     //点击返回
     connect(backBtn,&pushbutton::clicked,[=](){
         qDebug() <<"点击了返回按钮";
     });
}

void ChooseLevelScene::paintEvent(QPaintEvent *){
  //加载背景
  QPainter painter(this);
  QPixmap pix;
  pix.load(":/new/prefix1/pic/back2.jpg");
  painter.drawPixmap(0,0,this->width(),this->height(),pix);

  pix.load(":/new/prefix1/pic/omo.png");
  painter.drawPixmap((this->width()-pix.width())*0.1,20,pix.width()*0.8,pix.height()*0.8,pix);

}
